import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
import globalConfig from '@/core/framework/config/globalConfig'

const useGlobalConfigStore = create(
	persist<any>(
		(setState, getState) => {
			const globalState: any = {
				assemblySize: 'small',
				language: '',
				themeConfig: {
					// 默认 primary 主题颜色
					primary: '#1890ff',
					// 深色模式
					isDark: false,
					// 色弱模式(weak) || 灰色模式(gray)
					weakOrGray: '',
					// 面包屑导航
					breadcrumb: true,
					// 标签页
					tabs: true,
					// 页脚
					footer: false,
				},
			}
			return globalState
		},
		{
			name: `${globalConfig.storageKeyPrefix}.app.global`,
			storage: createJSONStorage(() => localStorage),
		},
	),
)

export default useGlobalConfigStore
